.NET Wrapper Continuous Source block
The .NET Wrapper Continuous Source block allows the user to integrate external .NET objects within the Architect environment. In this way, the user can add custom functionality, their own code, or third party libraries and objects to their solution.
Note that this connector may or may not be available on the user palette, according to your license type.
NOTE: CSense provides secure native blocks and operations for building analytics and solutions. The native capabilities provided by CSense can be extended by making use of this feature. When making use of this feature, please ensure that you have validated your extended functions to ensure that they perform as intended and do not introduce stability or security risks to your production system. Do not use scripts or components from untrusted sources.
Description
External .NET continuous source objects that contain custom functionality (e.g., own code, libraries, or components) can be integrated within the Architect environment using the .NET Continuous Wrapper Source block. Since Architect provides and manages runtime scheduling and interfacing, the third party .NET object only has to focus on its own functionality. This object must implement the IContinuousSourceBlock interface, the integrated object can then interface and communicate with any other Architect block.
The IContinuousSourceBlock interface is defined in the .NETWrapperInterface.DLL assembly. This interface is in the CSense.CSenseWrapper namespace. This assembly also contains a group of enumerations, classes and interfaces that can be used by, and passed to your object through the interface. These classes are defined in the Wrapper interface assembly.
These objects can be written in any .NET language with the only requirement that it supports .NET 2.0 or later. All objects are contained in .NET class library assembly files (DLL files) and need to be registered in Windows for clients to find them.
NOTE: One class library may contain multiple .NET objects.
A note on Multiple Execution Rates:
When different source blocks are used on one blueprint, it is possible to get identical execution rates resulting in more than one data value per timestamp, provided that none of the source blocks are a .NET Wrapper Source. (This situation needs to be taken into consideration when sinking data back to operating systems.)
If, however, one of the source blocks is a .NET Wrapper Source, the sources will NOT BE ABLE to have the same execution rate regardless of how the source block sampling periods are configured. This will lead to multiple execution rates when using a .NET Wrapper Source as a source in the blueprint.
If the same execution rate is required when using a .NET Wrapper Source as one of the sources, it is recommended that a Resampler block is used, linked to all the source blocks. Be aware that the Resampler block will always execute after the source blocks.
.NET wrapper Continuous source block
The IContinuousSourceBlock Interface:
All four interfaces have almost the same methods, they just differ in parameters. These methods can be explored in greater detail in the Block interface overview.
The IContinuousSourceBlock interface is required by the Continuous .NET Wrapper Source block. This interface is used when your object will be creating new output fields. The interface is defined as:
public interface ISourceBlock
{
DateTime FirstExecuteTime { get; }
bool IsAtEnd { get; }
DateTime NextExecuteTime { get; }
}
public interface IContinuousSourceBlock : ISourceBlock
{
UserControl GetConfigurationControl();
void Configure(UserControl control);
void UpdateOutputFields(OutputFields outputFields);
void CheckRunnability(IRunnabilityResult result);
void ExecutionStarted();
void Execute(DateTime executeTime, OutputValues outputs);
void ExecutionStopped();
}
Interfaces used in the IContinuousSourceBlock Interface:
There are interfaces and classes specific to the .NET Wrapper Source blocks. They are only used if your object will use any of the CSense Sources, such as the Continuous Source block and the Discrete Source block.
-
INeedCSenseSourceFactory: Interface that can be implemented by objects that implements any of the two source interfaces. This interface tells the .NET Wrapper Source block that your object requires the CSenseSourceFactory object.
-
CSenseSourceFactory: Abstract class containing a list of all available sources that can be created along with the creation method that will create a required CSense Sources. This object is passed to your object through the INeedCSenseSourceFactory interface.
-
CSenseSourceType: The CSense Source Type enumeration. The source type can either be discrete or continuous.
-
ICSenseSource: Interface to a CSense Source that was created through the CSenseSourceFactory object.
-
CSenseSourcePropertyType: Enumeration of CSense Source properties that can be set.
-
CSenseProperty: The CSense Source property class holding the property type and the new value.
Note: Only continuous CSense sources will be available if your object is used in the Continuous .NET Wrapper Source block.
Block Type
Historical IO
Input port
The .NET Wrapper Continuous Source block has no input port and a single output port. The contents of the output port are entirely determined by the source object.
Output port
When adding fields to the OutputFields container, the following must be remembered:
-
All field names must be valid field identifiers. This can be checked with the IsValidIdentifier static method on the Field class. It takes a string and returns true if it is a valid identifier, otherwise false. You can also make a string a valid identifier with the MakeValidIdentifier static method on the Field class.
-
The OutputFields container must have fields with unique names. You may not add two fields with the same name to the container.
-
Use the IsNameAllowed method on the OutputFields to see if the field name is allowed into the container.
-
Use the IsTypeAllowed method on the OutputFields to see if the field type is allowed into the container. The Continuous .NET Wrapper Source Block may only allow double fields if it is used within the Troubleshooter. The Continuous .NET Wrapper Source will allow all field types if it is used in the Architect.
The OutputValues container is a read-only container, but you may still change the timestamp, value and quality of the fields that is contained within the container. This OutputValues container will contain all the fields that you specified in the UpdateOutputFields method.
Functions performed on tags
The input values are sent through the .NET Wrapper block and the calculated output value(s) of the .NET object are placed in output fields of the .NET Wrapper block.
-
On the Quality, Value: If the quality or value of a field changes, the timestamp is changed. The new fields are user defined when configuring the output fields.
-
On the Timestamp: The timestamp may only increase. It may never be less than the last timestamp you set on that field.
Runnability
Your object is considered runnable unless you called the AddError method on the IRunnabilityResult interface supplied in the CheckRunnability method. The AddWarning method only adds warning messages, and will not mark your object as not runnable.
The minimum requirements for runnability on the .NET Continuous Wrapper block are:
The minimum requirements for runnability on the .NET Wrapper block are:
-
a valid .NET DLL object file is loaded
-
a valid .NET object is selected
-
Object requires a connection to a valid sink.
Terminology
-
.NET: The .NET framework is a large library of pre-coded solutions to common programming problems and manages the execution of programs written specifically for the framework.
-
.NET object: an component create within the .NET Framework
Related topics: